import {
  defineConfig,
  presetAttributify,
  presetIcons,
  presetTypography,
  presetUno,
  transformerDirectives,
  transformerVariantGroup,
} from 'unocss'

export default defineConfig({
  shortcuts: [
    ['flex-center', 'flex items-center justify-center'],
    ['flex-between', 'flex items-center justify-between'],
    ['flex-start', 'flex items-center justify-start'],
    ['flex-end', 'flex items-center justify-end'],
  ],
  rules: [
    [
      /^clamp-(\d+)$/,
      ([, d]) =>
        d === '1'
          ? {
              'overflow': 'hidden',
              'text-overflow': 'ellipsis',
              'white-space': 'nowrap',
            }
          : {
              '-webkit-line-clamp': d,
              'overflow': 'hidden',
              'text-overflow': 'ellipsis',
              'display': '-webkit-box',
              'white-space': 'normal',
              '-webkit-box-orient': 'vertical',
            },
    ],
  ],
  presets: [presetUno(), presetAttributify(), presetIcons(), presetTypography()],
  transformers: [transformerDirectives({ enforce: 'pre' }), transformerVariantGroup()],
})
